package com.example.readwrite;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

public class ReadTask implements Runnable {

    private SharedData sharedData;

    public ReadTask(SharedData sharedData) {
        this.sharedData = sharedData;
    }

    @Override
    public void run() {
        try {
            while (true) {
                char[] read = sharedData.read();
                System.out.println("read = " + Arrays.toString(read));
                TimeUnit.SECONDS.sleep(1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
